import requests



def send_one_msg(apikey,code,mobile):
    #发送单条短信
    url="https://sms.yunpian.com/v2/sms/single_sennd.json"
    text="您的验证码是{}，如非本人操作请忽略此条短信".format(code)  #format格式化"{0}，{1}".format("Hello","World")
    res = requests.post(url,data={
        "apikey":apikey,
        "mobile":mobile,
        "text":text

    })
    return res
if __name__=="__main__":
    res = send_one_msg("d6c4ddf50ab36611d2f52041a0b949e","123456","1886543916")
    import json
    res_json = json.loads(res.text)
    code = res_json["code"]
    msg = res_json["msg"]
    if code == 0:
        print("发送成功")
    else:
        print("发送失败：{}".format(msg))
    print(res.text)
